<!DOCTYPE html>
<html>
    <head>
        <title>Add Bars</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
        <script src="../resources/js/addBars.js"></script>
        <script src="../resources/js/admin.js"></script>
        <script src="../resources/js/logIn.js"></script>
        <link rel="stylesheet" type="text/css" href="../resources/css/admin.css">
        <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
    </head>
    <body>
        <?php include '../resources/templates/header_admin.php' ?>
        <script>
            $(document).ready(function() {
                 $.when(getClientInfo()).then(
                    function(location){
                        
                    }
                );
                $inputField = $("#postal_no");
                $outputField = $("#place");
                $inputField.keyup(function(){
                    if($inputField.val().match(/\d{4}/)) {
                        $.getJSON("http://adressesok.posten.no/api/v1/postal_codes.json?postal_code=" + $inputField.val() + "&callback=?",
                        function(data){
                            $outputField.val(data["postal_codes"][0].city);
                        });
                    } else{
                        $outputField.text("");
                    }
                });
            });
        </script>
        <div id="content-wrapper">
            <article id="content">
                <table id="new-bar-grid" class="responsive-table">
                    <tr>
                        <th>Name</th>
                        <th>Country</th>
                        <th>Postal No.</th>
                        <th>City</th>
                        <th>Address</th>
                        <th>CC</th>
                        <th>Beer Price</th>
                        <th>Description</th>
                        <th>Age Limit</th>
                        <th>Owner</th>
                        <th>Status</th>
                    </tr>
                    <tr id="row-0">
                        <td><input style="width: 8vw;" type="text" id="name" name="name" autofocus></td>
                        <td><select disabled id="country" name="country"><option value="Norway">Norway</option></select></td>
                        <td><input style="width: 3.5vw;" type="text" id="postal_no" name="postal_no"></td>
                        <td><input style="width: 6vw;" disabled type="text" id="place" name="place"></td>
                        <td><input style="width: 9vw;" type="text" id="address" name="address"></td>
                        <td><input style="width: 2vw;" type="number" id="cover_charge" name="cover_charge" value='0'></td>
                        <td><input style="width: 2vw;" type="number" id="beer_price" name="beer_price"></td>
                        <td><textarea id="description" name="description"></textarea></td>
                        <td><input style="width: 2vw;" type="number" id="age_limit" name="age_limit"></td>
                        <td><input style="width: 7vw;" type="text" id="business_user_id" name="business_user_id"></td>
                        <td><input style="width: 5vw;" type="text" disabled id="status_id" name="status_id"></td>
                        <td>
                            <div id="button-wrapper">
                                <input id="add-row-btn" class="button" type="button" onclick="addBarToGrid('new-bar-grid');" title="Add row">
                                <input id="reset-btn" class="button" type="button" onclick="reset('new-bar-grid');" title="Reset">
                                <input id="run-sql-btn" class="button" type="button" onclick="" title="Run SQL">
                            </div>
                        </td>
                    </tr>
                </table>
            </article>
        </div>
    </body>
    <?php include '../resources/templates/footer_admin.php' ?>
</html>